import { Component, OnInit } from '@angular/core';
import { NavParams, ModalController } from '@ionic/angular';
import { ToolService } from 'src/app/service/tool.service';
import { PopwinService } from 'src/app/service/popwin.service';

@Component({
  selector: 'app-accountrechargecardmodal',
  templateUrl: './accountrechargecardmodal.component.html',
  styleUrls: ['./accountrechargecardmodal.component.scss'],
})
export class AccountrechargecardmodalComponent implements OnInit {
  public cardData: any;
  public cash;//支付的金额
  public username: String = "";
  public cardName: String = "";
  public cardNo: String = "";
  public payTime: String = ToolService.getNowFormatDate();
  constructor(private navParams: NavParams, private popWin: PopwinService,private modalCtrl:ModalController) {
    this.cardData = this.navParams.get("params");
    this.cash = this.navParams.get("cash");
  }

  ngOnInit() { }
  /**
   * 关闭modal
   */
  closeModal() {
    this.modalCtrl.dismiss();
  }
  /**
   * 提交数据
   */
  onSubmit() {
    if (ToolService.isEmpty(this.username)) {
      this.popWin.toast("用户姓名必须填写");
      return;
    }
    if (ToolService.isEmpty(this.cardName)) {
      this.popWin.toast("银行名称必须填写");
      return;
    }
    if (ToolService.isEmpty(this.cardNo)) {
      this.popWin.toast("银行卡号必须填写");
      return;
    }
    if (ToolService.isEmpty(this.payTime)) {
      this.popWin.toast("存款时间必须填写");
      return;
    }
    this.modalCtrl.dismiss({
      userName:this.username,
      bankName:this.cardName,
      cardId:this.cardNo,
      depostitTime:this.payTime.substr(0, 10)
    });

  }

}
